package ae.pcfc.etks.online.common.domain;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Service entity. @author Mohtisham.Salahria 
 */
@Entity
@Table(name = "T_ETKS_SERVICE", schema = "ETKS_ONLINE_DBA")
@SequenceGenerator(name = "SQ_ETKS_SERVICE", sequenceName = "SQ_ETKS_SERVICE", initialValue = 1, allocationSize = 1)
public class Service implements java.io.Serializable {

	// Fields

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private Long serviceId;
	private String serviceNameEng;
	private String serviceNameArb;
	private String serviceStatus;
	private Date serviceCreateDate;
	private String serviceDefaultDeptCode;
	private String serviceDefault;
	private String serviceURL;
	private String serviceType;
	private Set<ServiceAttr> ServiceAttrs = new HashSet<ServiceAttr>(
			0);
	private Set<ServiceReq> ServiceReqs = new HashSet<ServiceReq>(
			0);
	private Set<ServiceDept> ServiceDepts = new HashSet<ServiceDept>(
			0);
	private Set<ServiceRole> ServiceRoles = new HashSet<ServiceRole>(
			0);
	// Constructors

	/** default constructor */
	public Service() {
	}

	/** minimal constructor */
	public Service(String serviceNameEng, String serviceNameArb,
			String serviceStatus, Date serviceCreateDate,
			String serviceDefaultDeptCode) {
		this.serviceNameEng = serviceNameEng;
		this.serviceNameArb = serviceNameArb;
		this.serviceStatus = serviceStatus;
		this.serviceCreateDate = serviceCreateDate;
		this.serviceDefaultDeptCode = serviceDefaultDeptCode;
	}

	/** full constructor */
	public Service(String serviceNameEng, String serviceNameArb,
			String serviceStatus, Date serviceCreateDate,
			String serviceDefaultDeptCode,
			Set<ServiceAttr> ServiceAttrs,
			Set<ServiceReq> ServiceReqs) {
		this.serviceNameEng = serviceNameEng;
		this.serviceNameArb = serviceNameArb;
		this.serviceStatus = serviceStatus;
		this.serviceCreateDate = serviceCreateDate;
		this.serviceDefaultDeptCode = serviceDefaultDeptCode;
		this.ServiceAttrs = ServiceAttrs;
		this.ServiceReqs = ServiceReqs;
	}

	// Property accessors
	@Id
	@GeneratedValue( strategy = GenerationType.SEQUENCE, generator="SQ_ETKS_SERVICE")
	@Column(name = "SERVICE_ID", unique = true, nullable = false, precision = 11, scale = 0)
	public Long getServiceId() {
		return this.serviceId;
	}

	public void setServiceId(Long serviceId) {
		this.serviceId = serviceId;
	}

	@Column(name = "SERVICE_NAME_ENG", nullable = false, length = 50)
	public String getServiceNameEng() {
		return this.serviceNameEng;
	}

	public void setServiceNameEng(String serviceNameEng) {
		this.serviceNameEng = serviceNameEng;
	}

	@Column(name = "SERVICE_NAME_ARB", nullable = false, length = 50)
	public String getServiceNameArb() {
		return this.serviceNameArb;
	}

	public void setServiceNameArb(String serviceNameArb) {
		this.serviceNameArb = serviceNameArb;
	}

	@Column(name = "SERVICE_STATUS", nullable = false, length = 1)
	public String getServiceStatus() {
		return this.serviceStatus;
	}

	public void setServiceStatus(String serviceStatus) {
		this.serviceStatus = serviceStatus;
	}

	@Temporal(TemporalType.DATE)
	@Column(name = "SERVICE_CREATE_DATE", nullable = false)
	public Date getServiceCreateDate() {
		return this.serviceCreateDate;
	}

	public void setServiceCreateDate(Date serviceCreateDate) {
		this.serviceCreateDate = serviceCreateDate;
	}

	@Column(name = "SERVICE_DEFAULT_DEPT_CODE", nullable = false, length = 5)
	public String getServiceDefaultDeptCode() {
		return this.serviceDefaultDeptCode;
	}

	public void setServiceDefaultDeptCode(String serviceDefaultDeptCode) {
		this.serviceDefaultDeptCode = serviceDefaultDeptCode;
	}
	
	@Column(name = "SERVICE_DEFAULT", length = 5)
	public String getServiceDefault() {
		return serviceDefault;
	}

	public void setServiceDefault(String serviceDefault) {
		this.serviceDefault = serviceDefault;
	}
	
	
	@Column(name = "SERVICE_URL", length = 200)
	public String getServiceURL() {
		return serviceURL;
	}

	public void setServiceURL(String serviceURL) {
		this.serviceURL = serviceURL;
	}

	@Column(name = "SERVICE_TYPE", nullable = true, length = 1)	
	public String getServiceType() {
		return serviceType;
	}

	public void setServiceType(String serviceType) {
		this.serviceType = serviceType;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "service")
	public Set<ServiceAttr> getServiceAttrs() {
		return this.ServiceAttrs;
	}

	public void setServiceAttrs(Set<ServiceAttr> ServiceAttrs) {
		this.ServiceAttrs = ServiceAttrs;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "service")
	public Set<ServiceReq> getServiceReqs() {
		return this.ServiceReqs;
	}

	public void setServiceReqs(Set<ServiceReq> ServiceReqs) {
		this.ServiceReqs = ServiceReqs;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "service", orphanRemoval=true)
	public Set<ServiceDept> getServiceDepts() {
		return ServiceDepts;
	}


	public void setServiceDepts(Set<ServiceDept> serviceDepts) {
		ServiceDepts = serviceDepts;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "service")
	public Set<ServiceRole> getServiceRoles() {
		return ServiceRoles;
	}


	public void setServiceRoles(Set<ServiceRole> serviceRoles) {
		ServiceRoles = serviceRoles;
	}
}